//
// Created by Administrator on 2021/5/24.
//

#include "iostream"

using namespace std;

void bubbleSort(int *arr, int len){
    for (int i = 0; i < len - 1; i++) {
        for (int j = 0; j < len - 1 - i; j++) {
            if (arr[j] > arr[j+1]){
                int temp = i;
                i = j;
                j = temp;
            }
        }
    }
}

void printArray(int *arr, int len){
    for (int i = 0; i < len; ++i) {
        cout << arr[i] << " ";
    }
    cout << endl;
}

int main(){

    int arr[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    int len = sizeof(arr) / sizeof(arr[0]);

    bubbleSort(arr, len);

    printArray(arr, len);

    system("pause");

    return 0;
}